package com.xnyzc.lhy.order.controller.capi.order;

import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.exception.PangException;
import com.xnyzc.lhy.common.penum.EErrorCode;
import com.xnyzc.lhy.common.util.CheckUtil;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.service.order.IOaCCostDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description 获取订单费用
 * @Author zhuyubin
 * @Date 2019/8/16 20:35
 **/
@RestController
@RequestMapping(value = "capi/costDetails")
public class OaCCostDetailsController {

    @Autowired
    private IOaCCostDetailsService iOaCCostDetailsService;

    @GetMapping(value = "getCostDetails")
    public Rv getCostDetails(String orderNo){
        Long userId = TokenUtil.getTokenUserId();
        if (CheckUtil.objIsEmpty(userId)){
            throw PangException.create(EErrorCode.tokenExpire);
        }
        String tag = TokenUtil.getTag();
        if (CheckUtil.objIsEmpty(tag)){
            throw PangException.create(EErrorCode.missingAuthArgs);
        }
        if (CheckUtil.objIsEmpty(orderNo)){
            throw PangException.create(EErrorCode.missingArg);
        }
        return Rv.wrap(iOaCCostDetailsService.getCostDetails(userId, tag, orderNo));
    }
}
